// 实现与MySQL交互
// var mysql = require('mysql');
// var $conf = require('../conf/conf');
// var $util = require('../util/util');
const $sql = require("./userSqlMapping");
const { query, handleToQuery } = require("./query");

// var pool  = mysql.createPool($util.extend({}, $conf.mysql));

// 向前台返回JSON方法的简单封装
var jsonWrite = function (res, ret) {
  if (typeof ret === "undefined") {
    res.json({
      code: "1",
      msg: "操作失败",
    });
  } else {
    res.json(ret);
  }
};

module.exports = {
  add: (userInfo = {}) => {
    const data = Object.values(userInfo);
    return query($sql.insert, data);
  },

  queryByPhoneAndPassword: (phone, password) => {
    return query($sql.queryByPhoneAndPassword, [phone, password]);
  },

  queryByPhone: (phone) => {
    return query($sql.queryByPhone, [phone]);
  },

  delete: () => {},
  update: () => {},
};
